<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 补充一:如果if语句对应的代码块只有一行,可以省略{}
    var price = 5
    var weight = 7
    var totalPrice = price * weight
    if (weight > 5) totalPrice -= 8
    console.log("总价格:", totalPrice)

    // 补充二:if(条件判断)
    var num = 123 //true
    if (num) console.log("num判断的代码执行")


  </script>
</body>

</html>